Brussels | ITP-2026-1 | Meysam Razagh | Sprint-3 | Practice TDD#79
Open
Epunch wants to merge 4 commits intoHackYourFutureBelgium:mainfrom
Open
Brussels | ITP-2026-1 | Meysam Razagh | Sprint-3 | Practice TDD#79Epunch wants to merge 4 commits intoHackYourFutureBelgium:mainfrom
Epunch wants to merge 4 commits intoHackYourFutureBelgium:mainfrom
Conversation
noahg9
reviewed
Apr 30, 2026
| } | ||
|
|
||
| return num + "th"; | ||
| } |
There was a problem hiding this comment.
This works for all numbers up to 20. Even better would be if you can make it work for all numbers. Right now 21 would output 21th instead of 21st and so on
Author
There was a problem hiding this comment.
@noahg9 I've refactored the function using the modulo operator to ensure it's scalable for all numbers. It now passes the new test cases. Thanks for the feedback!
| test("should return 'th' for numbers other than 1, 2, or 3", () => { | ||
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| expect(getOrdinalNumber(10)).toEqual("10th"); | ||
| }); |
There was a problem hiding this comment.
Add tests for numbers ending in 1, 2 or 3 after 20. They will fail with your current implementation
Author
There was a problem hiding this comment.
@noahg9 I've added the test cases for numbers ending in 1, 2, and 3 after 20 as requested. They are now passing with the updated logic in the main file.
…xceptions for 11-13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
In this PR, I practiced Test-Driven Development (TDD) by implementing three functions with their corresponding Jest tests:
countChar: A function that counts occurrences of a character in a string.repeat: A function that repeats a string a specified number of times, including handling edge cases like 0 and negative counts.getOrdinalNumber: A function that converts numbers to their ordinal format (1st, 2nd, 3rd, etc.).Questions
No questions, everything went smoothly!